package com.example.train.eurekaprovide.service.impl;

import com.example.train.eurekaprovide.entity.Employee;
import com.example.train.eurekaprovide.figen.JobFigen;
import com.example.train.eurekaprovide.mapper.EmployeeMapper;
import com.example.train.eurekaprovide.service.EmployeeService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

import java.util.List;

@Service
public class EmployeeServiceImpl implements EmployeeService {

    @Autowired
    JobFigen jobFigen;

    @Autowired
    EmployeeMapper employeeMapper;

    @Override
    public Employee selectById(Integer id) {
        Employee employee = employeeMapper.selectById(id);
        if (null != employee) {
            employee.setJobInfo(jobFigen.getJobInfoById(employee.getJobId()));
        }
        return employee;
    }

    @Override
    public List<Employee> selectAll() {
        return employeeMapper.selectAll();
    }
}
